import { createApp } from "vue";
import "./style.css";
import router from "@router/system.js";
import App from "./App.vue";
import store from "@store";
import Antd from 'ant-design-vue';
import 'ant-design-vue/dist/antd.css';
import * as antIcons from '@ant-design/icons-vue'
import moment from "moment";
import createStore from '@store/index.js'
const { state, dispatch } = createStore

const app = createApp(App)
Object.keys(antIcons).forEach(key => {
  app.component(key, antIcons[key])
})
// 添加到全局
app.config.globalProperties.$antIcons = antIcons
app.use(router)
  .use(store)
  .use(Antd)
  .mount("#app");
app.component('my-component', {
  /* ... */
})
setInterval(() => {
  dispatch('refreshToken', state.user.token)
}, 3600000)



// let orignalSetItem = window.localStorage.setItem;   // 原生localStorage.setItem方法
// localStorage.setItem = function (key, newValue) {
//   let setItemEvent = new Event("setItemEvent");  // 重写注册setItem
//   setItemEvent.key = key;
//   setItemEvent.newValue = newValue;
//   window.dispatchEvent(setItemEvent);            // 派发setItem
//   orignalSetItem.apply(this, arguments);         // 设置值
// }
// let SorignalSetItem = window.sessionStorage.setItem;   // 原生localStorage.setItem方法
// sessionStorage.setItem = function (key, newValue) {
//   let setItemEvent = new Event("setItemEvent");  // 重写注册setItem
//   setItemEvent.key = key;
//   setItemEvent.newValue = newValue;
//   window.dispatchEvent(setItemEvent);            // 派发setItem
//   SorignalSetItem.apply(this, arguments);         // 设置值
// }

